package com.haixee.parkdemo.common.response;

/**
 * @author GUIFENG GUO
 * 2020/3/22 8:01
 */
public final class ResUtil {

    public static ResResult success(Object object) {
        ResResult result = new ResResult();
        result.setData(object);
        result.setCode(CommonResEnum.SUCCESS.getCode());
        result.setMsg(CommonResEnum.SUCCESS.getMsg());
        return result;
    }


    public static ResResult success() {
        ResResult result = new ResResult();
        result.setCode(CommonResEnum.SUCCESS.getCode());
        result.setMsg(CommonResEnum.SUCCESS.getMsg());
        return result;
    }

    public static ResResult error(ResultPort resultEnum) {
        ResResult result = new ResResult();
        result.setCode(resultEnum.getCode());
        result.setMsg(resultEnum.getMsg());
        return result;
    }

    public static ResResult error(ResultPort resultEnum, String errMsg) {
        ResResult result = new ResResult();
        result.setCode(resultEnum.getCode());
        result.setMsg(errMsg);
        return result;
    }

    public static ResResult error(Integer code, String errMsg) {
        ResResult result = new ResResult();
        result.setCode(code);
        result.setMsg(errMsg);
        return result;
    }

    public static ResResult relay(Integer code, String errMsg) {
        ResResult result = new ResResult();
        result.setCode(code);
        result.setMsg(errMsg);
        return result;
    }
}
